package com.xiaoshuidi.cloud.module.contract.api.contract;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.contract.api.ContractTaxRateApi;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.ContractTaxRateDO;
import com.xiaoshuidi.cloud.module.contract.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.contract.enums.ErrorCodeConstants;
import com.xiaoshuidi.cloud.module.contract.service.contract.ContractTaxRateService;
import com.xiaoshuidi.cloud.module.contract.vo.ContractTaxRateVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@Validated
@RequiredArgsConstructor
public class ContractTaxRateApiImpl implements ContractTaxRateApi {

    @Resource
    private ContractTaxRateService contractTaxRateService;

    /**
     * 查询配置
     * @param apartmentId
     * @return
     */
    public CommonResult<ContractTaxRateVO> getContractTaxRate(@RequestParam("apartmentId") Long apartmentId) {
        ContractTaxRateDO contractTaxRate = contractTaxRateService.getContractTaxRate(apartmentId);
        return CommonResult.success(BeanUtil.copyProperties(contractTaxRate,ContractTaxRateVO.class));
    }
}
